package Net;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;

public class TcpClientDemo01 {
    public void test() {
        System.out.println("111");
    }

    public static void main(String[] args) throws IOException {
        InetAddress serverIp = InetAddress.getByName("127.0.0.1");
        int port = 999;
        Socket socket = new Socket(serverIp, port);
        OutputStream os = socket.getOutputStream();
        os.write("hellow".getBytes(StandardCharsets.UTF_8));
        try {
            os.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
